package com.day19;

public class Test2 {
    public static void main(String[] args) {
        int[] array1={1,2,3};
        int[] array2={4,5,6};
        array1[0]=100;
        array1[1]=300;

        System.out.println("两个数组的初始值为");
        for (int i=0;i<array1.length;i++){
            System.out.println("array1["+i+"]= "+array1[i]);
        }
        System.out.println("\t");
        for (int i=0;i<array2.length;i++){
            System.out.println("array2["+i+"]= "+array2[i]);
        }

        //把array2赋值给array1
       array1=array2;//复制数字必须在遍历操作前
       //遍历数组
        System.out.println("两个数组的初始值为");
        for (int i=0;i<array1.length;i++){
            System.out.println("array1["+i+"]= "+array1[i]);
        }
        System.out.println("\t");
        for (int i=0;i<array2.length;i++){
            System.out.println("array2["+i+"]= "+array2[i]);
        }
    }
}
